﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property
{
    /// <summary>
    /// Contains words that can be applied to input property instances. 
    /// </summary>
    public static class InputExtensionsReactive
    {
        /// <summary>
        /// <para>Create a new observable sequence subscription.</para>
        /// <para>( ! ) Don't forget to dispose of it.</para>
        /// </summary>
        /// <param name="inputSequence">Tell me what sequence to use as an Input
        /// for the object.</param>
        public static IDisposable FromObservable<T>(this IInput<T> source, IObservable<T> inputSequence)
        {
            if (source == null) throw new ArgumentNullException("source");

            return inputSequence.Subscribe<T>(o => source.Input = o);
        }
    }
}
